package com.situ.firmadmin.controller;


import com.situ.firmadmin.pojo.Area;
import com.situ.firmadmin.pojo.City;
import com.situ.firmadmin.pojo.Province;
import com.situ.firmadmin.service.IAddressService;
import com.situ.firmadmin.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/address")
public class AddressController {

    @Autowired
    private IAddressService addressService;

    @GetMapping("/selectAllProvince")
    public Result selectAllProvince(){
        List<Province> provinceList=addressService.selectAllProvince();
        return Result.ok(provinceList);
    }

    @GetMapping("/selectByPId/{pId}")
    public Result selectByPId(@PathVariable Integer pId){
        System.out.println("省ID："+pId);
        List<City> cityList=addressService.selectCityByP(pId);
        return Result.ok(cityList);
    }

    @GetMapping("/selectByCId/{cId}")
    public Result selectAreaByC(@PathVariable Integer cId){
        System.out.println("市ID："+cId);
        List<Area> areaList=addressService.selectAreaByC(cId);
        return Result.ok(areaList);
    }

}
